package com.xinou.daily_report.controller;


import com.xinou.common.base.config.ApiResponse;
import com.xinou.daily_report.PO.WeekPlanPO;
import com.xinou.daily_report.PO.WeekPlanUpdatePO;
import com.xinou.daily_report.VO.WeekPlanInfoVO;
import com.xinou.daily_report.VO.WeekPlanVO;
import com.xinou.daily_report.service.SysWeekPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-06-11
 */
@RestController
@RequestMapping("/mini/week-plan")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(tags = {"前台周计划"})
public class MiniWeekPlanController {
    private final SysWeekPlanService sysWeekPlanService;

    @PostMapping("/list")
    @ApiOperation("获取周报计划列表加筛选")
    @RequiresPermissions({"mini:week-plan:list"})
    public ApiResponse<WeekPlanInfoVO> weekPlanList(@RequestBody WeekPlanPO weekPlanPO){
        System.out.println(weekPlanPO);

        return sysWeekPlanService.weekPlanList(weekPlanPO);
    }

    @PostMapping("/save")
    @ApiOperation("添加周报计划")
    @RequiresPermissions({"mini:week-plan:save"})
    public ApiResponse<Void> weekPlanSave(@RequestBody WeekPlanUpdatePO weekPlanUpdatePO){
        System.out.println(weekPlanUpdatePO);
        return sysWeekPlanService.weekPlanSave(weekPlanUpdatePO);
    }

    @PostMapping("/update")
    @ApiOperation("修改周报计划")
    @RequiresPermissions({"mini:week-plan:update"})
    public ApiResponse<Void> weekPlanUpdate(@RequestBody WeekPlanUpdatePO weekPlanUpdatePO){
        System.out.println(weekPlanUpdatePO);

        return sysWeekPlanService.weekPlanUpdate(weekPlanUpdatePO);
    }


    @PostMapping("/delete")
    @ApiOperation("删除周报计划")
    @RequiresPermissions({"mini:week-plan:delete"})
    public ApiResponse<Void> weekPlanDelete(@RequestBody WeekPlanPO weekPlanPO){
        return sysWeekPlanService.weekPlanDelete(weekPlanPO);
    }

    @PostMapping("/getById")
    @ApiOperation("根据id查询周报计划")
    @RequiresPermissions({"mini:week-plan:getById"})
    public ApiResponse<WeekPlanInfoVO> weekPlanGetById(@RequestBody WeekPlanPO weekPlanPO){
        return sysWeekPlanService.weekPlanGetById(weekPlanPO);
    }

}

